const express = require('express');
const path = require('path');
const cookieParser = require('cookie-parser');
const bodyParser = require('body-parser')
const logger = require('morgan');
const cors = require('cors');
require('dotenv').config();
require('./run');

const app = express();

app.use(logger('dev'));
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(bodyParser.text({type: '*/xml'}))
// cors 跨域配置

const corsOptions = {
//   origin: ['https://clwy.cn', 'http://localhost:63342', 'http://localhost:3000'],
};

app.use(cors(corsOptions));

// 路由

const routers = require('./config/router');
app.use(routers);
module.exports = app;
